<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

//echo "bootstrap\\app.php<br/>";
//echo realpath(__DIR__.'/../');// "F:\study\study-php-laravel\app53x"。

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);
HLLogh1('bootstrap\\app.php');
HLError('$app->instances 是');
foreach ($app->instances as $key => $value) {
	HLLog($key);
	if (is_string($value)) {
		HLLog("--------" . $value);
	} else {
		HLLog('--------' . get_class($value));
	}
}
/*
app
--------Illuminate\Foundation\Application
Illuminate\Container\Container
--------Illuminate\Foundation\Application
events
--------Illuminate\Events\Dispatcher
path
--------F:\study\study-php-laravel\app53x\app
path.base
--------F:\study\study-php-laravel\app53x
path.lang
--------F:\study\study-php-laravel\app53x\resources\lang
path.config
--------F:\study\study-php-laravel\app53x\config
path.public
--------F:\study\study-php-laravel\app53x\public
path.storage
--------F:\study\study-php-laravel\app53x\storage
path.database
--------F:\study\study-php-laravel\app53x\database
path.resources
--------F:\study\study-php-laravel\app53x\resources
path.bootstrap
--------F:\study\study-php-laravel\app53x\bootstrap

*/

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

/*
经过测试
namespace Hello\World\App;
class Amen {...}
打印
var_dump(Amen::class);
结果：string(20) "Hello\World\App\Amen"
*/

// HLLogh1('bootstrap\\app.php');
// HLError('$app->singleton(Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class)');
$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    App\Http\Kernel::class
);
// HLLogh1('bootstrap\\app.php');
// HLError('$app->singleton(Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class)');
// HLLog('$app->instances');
// HLVar($app->instances);
// HLLog('$app->aliases');
// HLVar($app->aliases);
// HLLog('$app->bindings');
// HLVar($app->bindings);

// HLLogh1('bootstrap\\app.php');
// HLError('$app->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class)');
$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);
// HLLogh1('bootstrap\\app.php');
// HLError('$app->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class)');
// HLLog('$app->instances');
// HLVar($app->instances);
// HLLog('$app->aliases');
// HLVar($app->aliases);
// HLLog('$app->bindings');
// HLVar($app->bindings);

// HLLogh1('bootstrap\\app.php');
// HLError('$app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class)');
$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);
// HLLogh1('bootstrap\\app.php');
// HLError('$app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class)');
// HLLog('$app->instances 键名');
// HLVar(array_keys($app->instances));
// HLLog('$app->aliases 键名');
// HLVar(array_keys($app->aliases));
// HLLog('$app->$bindings 键名');
// HLVar(array_keys($app->bindings));

// 在这种情况下的结论
// 这种情况指的是：
// vendor\laravel\framework\src\Illuminate\Foundation\Application.php 中的构造方法内部只执行 registerBaseBindings(),
// 而 registerBaseBindings() 内执行前面两个操作。
// 到这里：
// $app->instances 总是只有一个，也就是得到 $app 是存放的 $app 自己。
// ["app"]=> object(Illuminate\Foundation\Application)#3 (29)
// $app->aliases 还是空数组。
// $app->bindings 一共有三个元素，每次执行 singleton() 添加一个：
/*
array(3) {
  ["Illuminate\Contracts\Http\Kernel"]=>
  array(2) {
    ["concrete"]=>
    object(Closure)#2 (3) {
      ["static"]=>
      array(2) {
        ["abstract"]=>
        string(32) "Illuminate\Contracts\Http\Kernel"
        ["concrete"]=>
        string(15) "App\Http\Kernel"
      }
      ["this"]=>
      object(Illuminate\Foundation\Application)#3 (29) {...}
	  ["parameter"]=>
      array(2) {
        ["$container"]=>
        string(10) "" 查看网页源代码时是 string(10) "<required>"
        ["$parameters"]=>
        string(10) "" 查看网页源代码时是 string(10) "<optional>"
      }
    }
    ["shared"]=>
    bool(true)
  }

  ["Illuminate\Contracts\Console\Kernel"]=>
  array(2) {
    ["concrete"]=>
    object(Closure)#4 (3) {
      ["static"]=>
      array(2) {
        ["abstract"]=>
        string(35) "Illuminate\Contracts\Console\Kernel"
        ["concrete"]=>
        string(18) "App\Console\Kernel"
      }
      ["this"]=>
      object(Illuminate\Foundation\Application)#3 (29) {...}
	  ["parameter"]=>
      array(2) {
        ["$container"]=>
        string(10) "" 查看网页源代码时是 string(10) "<required>"
        ["$parameters"]=>
        string(10) "" 查看网页源代码时是 string(10) "<optional>"
      }
    }
    ["shared"]=>
    bool(true)
  }

  ["Illuminate\Contracts\Debug\ExceptionHandler"]=>
  array(2) {
    ["concrete"]=>
    object(Closure)#5 (3) {
      ["static"]=>
      array(2) {
        ["abstract"]=>
        string(43) "Illuminate\Contracts\Debug\ExceptionHandler"
        ["concrete"]=>
        string(22) "App\Exceptions\Handler"
      }
      ["this"]=>
      object(Illuminate\Foundation\Application)#3 (29) {...}
	  ["parameter"]=>
      array(2) {
        ["$container"]=>
        string(10) "" 查看网页源代码时是 string(10) "<required>"
        ["$parameters"]=>
        string(10) "" 查看网页源代码时是 string(10) "<optional>"
      }
    }
    ["shared"]=>
    bool(true)
  }
}

*/

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;
